# 1、图片链接
# 2、星级
# 3、书名
# 4、价格
import requests
import re
# from lxml import etree

url = 'https://books.toscrape.com/'
response = requests.get(url)
print(response.status_code)
# print(response.text)
html = response.text

# # re的使用
# # 1、得到一个patern
title_pa = re.compile('<img src="(.*?)" alt="[\s\S]*?" class="thumbnail">')
title2_pa = re.compile('<a href="[\s\S]*?" title="(.*?)">[\s\S]*?')
title3_pa = re.compile('<p class="price_color">(.*?)<')
intro_pa = re.compile('<p class="star-rating\s(.*?)">')
# 2、通过re查找
title = title_pa.findall(html)
for i  in title:
    print(i)
intro = intro_pa.findall(html)
print(intro)
title = title2_pa.findall(html)
for i  in title:
    print(i)
title = title3_pa.findall(html)
for i  in title:
    print(i)